{% extends 'student/base.html' %}
{% load customer_filters %}
{% load static %}
{% load student_customer_tags %}
{% block title %}学生管理系统{% endblock %}
{% block section %}学生列表{% endblock %}
{% block index %}
    <link rel="stylesheet" href="{% static 'student/css/index.css' %}">
    <form class="form-inline" method="post" action={% url 'student:index' %}>
        {% csrf_token %}
        <div class="form-group">
            <label class="sr-only" for="search">搜索</label>
            <input type="text" class="form-control" id="search" name="search" placeholder="请输入名字、qq或电话..." {% if search %}value="{{ search }}"{% endif %}>
        </div>
        <button type="submit" class="btn btn-default" >搜索</button>
        <a type="reset" class="btn btn-primary" href={{ request.path }}>重置</a>
        <a type="button" class="btn btn-primary" href={% url 'student:student_edit' 0 %}>添加</a>
    </form>
    <div class="table-responsive">
    <table class="table table-striped">
  <thead>
    <tr>
      <th>序号</th>
      <th>名字</th>
      <th>年龄</th>
      <th>性别</th>
      <th>qq</th>
      <th>电话</th>
      <th>操作</th>
    </tr>
  </thead>
  <tbody>
    {% for stu in sts %}
    <tr>
        <td><a href={% url 'student:detail' stu.id %}>{{ forloop.counter }}</a></td>
        <td>{{ stu.name }}</td>
        <td>{{ stu.age }}</td>
        <td>{{ stu.sex|to_sex }}</td>
        <td>{{ stu.qq }}</td>
        <td>{{ stu.phone }}</td>
        <td>
            <a type="button" class="btn btn-danger"  name="is_delete"  href={% url 'student:is_delete' stu.id %}>删除</a>
            <a type="button" class="btn btn-primary" href={% url 'student:student_edit' stu.id %}>编辑</a>
        </td>
    </tr>
    {% endfor %}
  </tbody>
</table>
</div>
    <nav aria-label="Page navigation">
        <ul class="pagination">
                {% pagination_html %}
{#            <li>#}
{#                <a {% if page > 1 %} href="{% url 'student:index' %}?page={{ page|add:-1}}&per_page={{ per_page }}" {% endif %} aria-label="Previous">#}
{#                <span aria-hidden="true">上一页</span>#}
{#                </a>#}
{#            </li>#}
{#                {% if page > 1 %}#}
{#            <li ><a  href='{{ request.path }}?page={{ page|add:-1 }}&per_page={{ per_page }}' >{{ page|add:-1 }}</a></li>#}
{#                {% endif %}#}
{#            <li class="active" ><a  href='{% url 'student:index' %}?page={{ page }}&per_page={{ per_page }}' >{{ page }}</a></li>#}
{#                {% if page < total_page %}#}
{#            <li {% if page == 10 %}class="active" {% endif %}><a  href='{% url 'student:index' %}?page={{ page|add:1 }}&per_page={{ per_page }}' >{{ page|add:1 }}</a></li>#}
{#                {% endif %}#}
{#            <li>#}
{#                <a {% if page < total_page %} href="{% url 'student:index' %}?page={{ page|add:1}}&per_page={{ per_page }}" {% endif %} aria-label="Next">#}
{#                    <span aria-hidden="true">下一页</span>#}
{#                </a>#}
{#            </li>#}

            <li>
                <div class="btn-group">
              <button type="button" class="btn btn-default dropdown-toggle" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
                条/页 <span class="caret"></span>
              </button>
              <ul class="dropdown-menu">
                   <li><a href="{{ request.path }}?page=1&per_page=5">5条/页</a></li>
                   <li><a href="{{ request.path }}?page=1&per_page=10">10条/页</a></li>
                   <li><a href="{{ request.path }}?page=1&per_page=20">20条/页</a></li>
              </ul>
                </div>
            </li>
        </ul>
    </nav>
{% endblock %}